package com.example.mybatis.controller;

import com.example.mybatis.pojo.User;
import com.example.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/m")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/queryAll")
    public List<User> getUserList(){
        return userService.getUserList();
    }

    @GetMapping("/query/{id}")
    public User getUserById(@PathVariable("id") Integer id){
        User user = userService.getUserById(id);
        return user;
    }

    @GetMapping("/delete/{id}")
    public Boolean deleteById(@PathVariable("id") Integer id){
        Boolean flag = false;
        if( userService.deleteById(id) > 0)
            flag = true;
        return flag;
    }

}
